﻿@page "/log"
@using DynamicQuartz.Web.Service
@inject LogService  logService
<PageTitle>日志</PageTitle>
<style>
    li{
        cursor: Pointer;
        font-size:14px
        
    }
    li:hover{
            background-color: #f2f2
    }
</style>
<h1>日志查看</h1>


@if (files == null)
{
    <p><em>Loading...</em></p>
}
else
{
    <div style="display:flex">
        <div style="flex:0.2">
            <ul>
                @foreach (var log in files)
                {
                    <li @onclick="() => GetFiles(log)"> @log.Replace(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log"), "") </li>
                }

            </ul>

        </div>
        <div style="flex:0.3">
           
            <ul>
                @foreach (var log in logs)
                {
                    <li @onclick="() =>open(log)"> @log.Replace(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log"), "")</li>
                }
            </ul>
        </div>
        <div style="flex:0.5">
        <p>
            @content
        </p>
        </div>
    </div>
 


}

@code {
    private List<string> files;
    private List<string> logs = new List<string>();
    string content;
    protected override async Task OnInitializedAsync()
    {
        files = logService.GetLogDirectories();
    }

    private void GetFiles(string path)
    {
        logs = logService.GetLogFile(path);
        content = null;
    }

    private void open(string path)
    {
        content = logService.Open(path);
    }
}
